//
//  InputTopCell.m
//  OperationPro
//
//  Created by yaxue wang on 2017/1/3.
//  Copyright © 2017年 展鸿科技. All rights reserved.
//

#import "InputTopCell.h"
#import "InputModel.h"

@interface InputTopCell()
@property (nonatomic, strong) UIImageView *headImg;
@property (nonatomic, strong) UIImageView *timeImg;
@property (nonatomic, strong) UILabel *nameLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *stateLab;
@property (nonatomic, strong) UILabel *line;

@end

@implementation InputTopCell

- (void)initView{
    [super initView];
    self.backgroundColor =[UIColor whiteColor];
    self.line =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 0.5)];
    [self addSubview:self.line];
    
    self.line.backgroundColor =C(@"E5E5E5");
    
    self.headImg=[[UIImageView alloc]init];
    [self addSubview:self.headImg];
    [self.headImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.size.mas_equalTo(CGSizeMake(50, 50));
        make.centerY.equalTo(self);
    }];
    self.headImg.layer.masksToBounds=YES;
    self.headImg.layer.cornerRadius=25;
    
    self.nameLab = [[UILabel alloc]init];
    [self addSubview:self.nameLab];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImg.mas_right).offset(15);
        make.top.equalTo(self).offset(20);
        make.right.equalTo(self).offset(-10);
    }];
    self.nameLab.textColor =MainColor;
    self.nameLab.font =F(15);
    
    
    UIImage *timeImage=[UIImage imageNamed:@"Ico_home_time"];
    self.timeImg=[[UIImageView alloc]init];
    [self addSubview:self.timeImg];
    self.timeImg.image=timeImage;
    [self.timeImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab);
        make.size.mas_equalTo(CGSizeMake(timeImage.size.width, timeImage.size.height));
        make.bottom.equalTo(self.mas_bottom).offset(-5);
    }];
    
    self.timeLab =[[UILabel alloc]init];
    [self addSubview:self.timeLab];
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeImg.mas_right).offset(5);
        make.centerY.equalTo(self.timeImg);
        //        make.bottom.equalTo(self.mas_bottom).offset(-12);
    }];
    self.timeLab.font =F(12);
    self.timeLab.textColor =LightFontColor;
    
    self.stateLab = [[UILabel alloc] init];
    [self addSubview:self.stateLab];
    [self.stateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.centerY.equalTo(self.timeImg);
        make.width.equalTo(@(50));
        make.height.equalTo(@(20));
        
    }];
    self.stateLab.textColor =[UIColor whiteColor];
    self.stateLab.layer.masksToBounds=YES;
    self.stateLab.layer.cornerRadius=3;
    self.stateLab.textAlignment=NSTextAlignmentCenter;
    self.stateLab.font =F(10);
    
    
    
    [self bk_whenTapped:^{
        if (self.btnBlock) {
            self.btnBlock(self,InputCellType_Detail,nil);
        }
        
    }];
    
    
}
- (void)setModel:(id)model
{
    InputModel *order = model;
    self.headImg.image= [UIImage imageNamed:@"Ico_home_bank"];
    
    self.nameLab.text=order.H_inst_name;
    self.timeImg.image =[UIImage imageNamed:@"Ico_home_time"];
    
    NSString *timeString = [order.H_created  substringWithRange:NSMakeRange(0, 16)];
    
    self.timeLab.text=timeString;
    if (order.H_state ==nil||[order.H_state isEqualToString:@""])
    {
        
    }else
    {
        NSInteger num=[order.H_state integerValue];
        if (num==4||num==5)
        {
            //处理中和待挂起为 处理中
            self.stateLab.text=@"处理中";
            self.stateLab.backgroundColor=C(@"feab9d");
            
        }else if(num==0)
        {
            self.stateLab.text=@"待分配";
            self.stateLab.backgroundColor=C(@"feab9d");
            
        }else if(num==1)
        {
            self.stateLab.text=@"待接单";
            self.stateLab.backgroundColor=C(@"e0e0e0");
            
        }else if(num==2)
        {
            self.stateLab.text=@"待处理";
            self.stateLab.backgroundColor=C(@"feab9d");
            
        }else if(num==6)
        {
            self.stateLab.text=@"挂起中";
            self.stateLab.backgroundColor=C(@"feab9d");
            
        }else if(num ==97)
        {
            self.stateLab.text =@"已撤销";
            self.stateLab.backgroundColor=C(@"e0e0e0");
            
        }else if (num ==99||num==98) {
            
            self.stateLab.text =@"已完成";
            self.stateLab.backgroundColor=C(@"e0e0e0");
            
            
        }else
        {
            //待确认 为空
            self.stateLab.text=@"";
        }
    }
    
    
}



@end
